import Main from '@/views/Main.vue'
// import CmsMain from '@/views/CmsMain.vue'
// import SystemMain from '@/views/SystemMain.vue'
import CommonIndex from '@/views/common-index.vue'

export const helloRouter = {
  path: '/hello',
  name: 'HelloWorld',
  component: () => import('@/views/HelloWorld.vue')
}

//  其他按钮路由
export const otherRouter = {
  path: '/',
  name: 'other-router',
  redirect: '/home',
  component: CommonIndex,
  meta: {
    title: '首页'
  },
  children: [
    {
      path: '/system/user/edit',
      name: 'system-user-edit',
      meta: {
        title: '用户编辑'
      },
      component: () => import('@/views/system/user-auth/user-edit.vue')
    },
    {
      path: '/system/role/edit',
      name: 'system-role-edit',
      meta: {
        title: '角色编辑'
      },
      component: () => import('@/views/system/user-auth/role-edit.vue')
    },
    {
      path: '/system/menu/edit',
      name: 'system-menu-edit',
      meta: {
        title: '菜单编辑'
      },
      component: () => import('@/views/system/setting/menu-edit.vue')
    }
  ]
}
//  系统模块
export const systemRouter = {
  path: '/home',
  name: 'home',
  redirect: '/system/index',
  component: CommonIndex,
  icon: 'settings',
  meta: {
    title: '系统管理'
  },
  children: [
    {
      path: '/system/index',
      name: 'system-index',
      icon: 'settings',
      meta: {
        title: '系统主页'
      },
      component: () => import('@/views/system/system-index.vue')
    },
    {
      path: '/system/table',
      name: 'system-table',
      icon: 'settings',
      meta: {
        title: '列表模版'
      },
      component: () => import('@/views/system/system-index.vue')
    },
    {
      path: '/system/form',
      name: 'system-form',
      icon: 'settings',
      meta: {
        title: '表单模版'
      },
      component: () => import('@/views/system/system-user-edit.vue')
    },
    {
      path: '/system/userauth',
      name: 'system-user-auth',
      icon: 'settings',
      meta: {
        title: '管理员中心'
      },
      component: CommonIndex,
      children: [
        {
          path: '/system/user',
          name: 'system-user',
          icon: 'settings',
          meta: {
            title: '用户列表',
            keepAlive: true
          },
          component: () => import('@/views/system/user-auth/user.vue')
        },
        {
          path: '/system/role',
          name: 'system-role',
          icon: 'settings',
          meta: {
            title: '角色列表'
          },
          component: () => import('@/views/system/user-auth/role.vue')
        }
      ]
    },
    {
      path: '/system/setting',
      name: 'system-setting',
      icon: 'settings',
      meta: {
        title: '系统设置'
      },
      component: CommonIndex,
      children: [
        {
          path: '/system/menu',
          name: 'system-menu',
          icon: 'android-menu',
          meta: {
            title: '菜单管理'
          },
          component: () => import('@/views/system/setting/menu.vue')
        }
      ]
    },
    {
      path: '/system/form',
      icon: 'android-checkbox',
      name: 'form',
      meta: {
        title: '表单编辑'
      },
      component: CommonIndex,
      children: [
        {
          path: '/system/form/artical-publish',
          meta: {
            title: '文章发布'
          },
          name: 'artical-publish',
          icon: 'compose',
          component: () => import('@/views/form/article-publish/article-publish.vue')
        },
        {
          path: '/system/form/workflow',
          meta: {
            title: '工作流'
          },
          name: 'workflow',
          icon: 'arrow-swap',
          component: () => import('@/views/form/work-flow/work-flow.vue')
        }

      ]
    }
  ]
}

//  内容模块
export const cmsRouter = {
  path: '/cms',
  name: 'cms',
  redirect: '/cms/index',
  component: CommonIndex,
  icon: 'ios-paper',
  meta: {
    title: '内容管理'
  },
  children: [
    {
      path: '/cms/index',
      name: 'cms-index',
      icon: 'ios-paper',
      meta: {
        title: '内容主页'
      },
      component: () => import('@/views/cms/cms-index.vue')
    }
  ]
}

export const appRouter = {
  path: '/',
  name: 'home',
  redirect: '/home',
  meta: {
    title: '主页'
  },
  component: Main,
  children: [
    systemRouter,
    cmsRouter,
    otherRouter
  ]
}

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: 'Login - 登录'
  },
  component: () => import('@/views/login.vue')
}

export const page404 = {
  path: '/*',
  name: 'error-404',
  meta: {
    title: '404-页面不存在'
  },
  component: () => import('@/views/error-page/404.vue')
}

export const page403 = {
  path: '/403',
  meta: {
    title: '403-权限不足'
  },
  name: 'error-403',
  component: () => import('@//views/error-page/403.vue')
}

export const page500 = {
  path: '/500',
  meta: {
    title: '500-服务端错误'
  },
  name: 'error-500',
  component: () => import('@/views/error-page/500.vue')
}

export const routers = [
  helloRouter,
  loginRouter,
  appRouter,
  page500,
  page403,
  page404
]
